package system

import (
	"github.com/gogf/gf/v2/frame/g"
	"server/api"
	"server/internal/model"
)

type CrontabCreateReq struct {
	g.Meta     `path:"/system/crontab/create" tags:"系统管理-定时任务" method:"post" summary:"新增" description:"定时任务"`
	CategoryID int64  `v:""`
	Title      string `v:"required" dc:"任务标题"`
	Name       string `v:"required" dc:"任务名称"`
	Params     string `v:"" dc:"参数"`
	Pattern    string `v:"required" dc:"表达式"`
	Policy     int    `v:"required" dc:"策略"`
	Count      int    `v:"required" dc:"执行次数"`
	Sort       int    `v:"required" dc:"排序"`
	Status     int    `v:"required" dc:"状态"`
	Remark     string `v:"" dc:"任务备注"`
}
type CrontabCreateRes struct {
	Id int64 `json:"id"`
}

type CrontabUpdateReq struct {
	g.Meta     `path:"/system/crontab/update" tags:"系统管理-定时任务" method:"post" summary:"编辑" description:"定时任务"`
	Id         int64  `v:"required" dc:"任务ID"`
	CategoryID int64  `v:""`
	Title      string `v:"required" dc:"任务标题"`
	Name       string `v:"required" dc:"任务名称"`
	Params     string `v:"" dc:"参数"`
	Pattern    string `v:"required" dc:"表达式"`
	Policy     int    `v:"required" dc:"策略"`
	Count      int    `v:"required" dc:"执行次数"`
	Sort       int    `v:"required" dc:"排序"`
	Status     int    `v:"required" dc:"状态"`
	Remark     string `v:"" dc:"任务备注"`
}
type CrontabUpdateRes struct {
	Affected int64 `json:"affected" dc:"影响的行数"`
}

type CrontabDeleteReq struct {
	g.Meta `path:"/system/crontab/delete" tags:"系统管理-定时任务" method:"post" summary:"删除" description:"定时任务"`
	Id     int64 `v:"required" dc:"任务ID"`
}
type CrontabDeleteRes struct {
	Affected int64 `json:"affected" dc:"影响的行数"`
}

type CrontabListReq struct {
	g.Meta `path:"/system/crontab/list" tags:"系统管理-定时任务" method:"GET" summary:"列表" description:"配置项列表"`
	api.PagerReq
	CategoryId int64  `v:""`
	Title      string `dc:"标题"`
	Name       string `dc:"名称"`
}
type CrontabListRes struct {
	List  []model.CrontabOutput `json:"list" dc:"列表数据"`
	Total int                   `json:"total" dc:"总数据"`
}

type CrontabRegisterListReq struct {
	g.Meta `path:"/system/crontab/registerList" tags:"系统管理-定时任务" method:"GET" summary:"列表" description:"已注册的定时任务列表"`
}
type CrontabRegisterListRes struct {
	List []string `json:"list" dc:"列表数据"`
}

type CrontabLogListReq struct {
	g.Meta `path:"/system/crontab/logs" tags:"系统管理-定时任务" method:"GET" summary:"获取定时任务的相关日志" description:"获取定时任务的相关日志"`
	Id     int64  `v:"required" dc:"任务ID"`
	Date   string `v:"required" dc:"日期"`
}
type CrontabLogListRes struct {
	List []string `json:"list" dc:"列表数据"`
}

type CrontabCategoryCreateReq struct {
	g.Meta `path:"/system/crontabCategory/create" tags:"系统管理-定时任务分类" method:"post" summary:"新增" description:"新增定时任务分类"`
	Name   string `v:"required"`
	Remark string `v:""`
}
type CrontabCategoryCreateRes struct {
	ID int64 `json:"id"`
}

type CrontabCategoryUpdateReq struct {
	g.Meta `path:"/system/crontabCategory/update" tags:"系统管理-定时任务分类" method:"post" summary:"编辑" description:"编辑定时任务分类"`
	ID     int64  `v:"required"`
	Name   string `v:"required"`
	Remark string `v:""`
}
type CrontabCategoryUpdateRes struct {
	Result int64 `json:"result"`
}

type CrontabCategoryDeleteReq struct {
	g.Meta `path:"/system/crontabCategory/delete" tags:"系统管理-定时任务分类" method:"post" summary:"删除" description:"删除定时任务分类"`
	ID     int64 `v:"required"`
}
type CrontabCategoryDeleteRes struct {
	Result int64 `json:"result"`
}

type CrontabCategoryListReq struct {
	g.Meta `path:"/system/crontabCategory/list" tags:"系统管理-定时任务分类" method:"GET" summary:"列表" description:"定时任务列表"`
	api.PagerReq
	Code string `dc:"标识符"`
	Name string `dc:"名称"`
}
type CrontabCategoryListRes struct {
	Total int                                   `json:"total"`
	List  []model.SystemCrontabCategoryListItem `json:"list"`
}
